<div id="mess"><?php if (isset($mess)) echo $mess; ?></div>
<div id="form">
    <table>
        <?php
        $this->form_validation->set_error_delimiters('<span class="error">', '</span>');
        /*___________________________USER___________________________*/

        foreach ($users as $user) { $pole_users[$user['id']] = $user['surname']." ". $user['first_name'];}
        isset($_POST['user']) ? $selected = $_POST['user'] : $selected = "";
        echo form_open(base_url() . 'admin/editevent');
        echo "<tr><td>" . form_label('Vyhľadať podľa používateľa :', 'user') . "</td><td>" . form_dropdown('user', $pole_users, $selected) . "</td>";
        echo "<td>" . form_submit('submit', 'zobraz', 'class="submit_edit"') . "</td></tr>";
        echo form_close();
        
        
        /*___________________________TYP___________________________*/
        
        foreach ($types as $type) { $pole_type[$type['id']] = $type['event_type']; }
        isset($_POST['type']) ? $selected = $_POST['type'] : $selected = "";
        echo form_open(base_url() . 'admin/editevent');
        echo "<tr><td>" . form_label('Vyhľadať podľa typu eventu: ', 'type') . "</td><td>" . form_dropdown('type', $pole_type, $selected) . "</td>";
        echo "<td>" . form_submit('submit', 'zobraz', 'class="submit_edit"') . "</td></tr>";
        echo form_close();

        /*___________________________ROOM___________________________*/
        
        foreach ($rooms as $room) { $pole_type[$room['id']] = $room['room_name']; }
        isset($_POST['room']) ? $selected = $_POST['room'] : $selected = "";
        echo form_open(base_url() . 'admin/editevent');
        echo "<tr><td>" . form_label('Vyhľadať podľa miestnosti: ', 'room') . "</td><td>" . form_dropdown('room', $pole_type, $selected) . "</td>";
        echo "<td>" . form_submit('submit', 'zobraz', 'class="submit_edit"') . "</td></tr>";
        echo form_close();
        
        
        ?>    
    </table>
    <?php
    if ($events != "") {
        echo "<table id='events' cellspacing='1' cellpadding='4'>";
        if ($events == false)
            echo "<tr class='row1'><td><b>Nenašli sa žiadne eventy</b></td><tr>";
        else {
              
              echo "<tr id='hlavicka'> <td>#</td> <td>názov eventu</td> <td>typ eventu</td> <td>termín eventu</td> <td>od</td> 
                    <td>do</td> <td>miestnosť</td> <td>editovať</td> <td>zmazať</td> </tr>";
            $i = 0;
            $js = "return confirm('Označený event bude natrvalo vymazaný!')";
            foreach ($events as $event) {
                $i++;

                echo "<tr class = 'row" . ($i % 2) . "'>";
                echo "<td>" . $i . "</td>";
                echo "<td>". $event["description"]."</td>";
                echo "<td>" . getEventType($event["event_type"]) . "</td>";
                echo "<td>" . $event["event_day"] . "</td>";
                echo "<td>" . getStringTimeFromMinutes($event["start_time"]) . "</td>";
                echo "<td>" . getStringTimeFromMinutes($event["end_time"]) . "</td>";
                echo "<td>" . getRoomName($event["room_id"]) . "</td>";
                echo '<td><a href="'.base_url()."admin/edit/".$event["id"].'" title="edituj event"  >edituj</a></td>';
                echo '<td><a href="'.base_url()."admin/deleteevent/".$event["id"].'" title="zmazat event" onclick="'.$js.'" >zmazať</a></td>';
                echo "</tr>";
                
            }
           
            
        }
        echo "</table>";
    }
    ?>    

</div>
